<template>
	<view class="page-warpper">
		<u-tabs :list="list" :is-scroll="false" :current="current" @change="setCurrent" v-if="showTab"></u-tabs>
		<view v-show="current == 0">
			<u-empty text="暂无申请记录" :show="noApplyData" mode="list"></u-empty>
			<view v-show="!noApplyData">
				<view v-for="(item,index) in applyList" :key="index">
					<view class="" @click="toDetail(item, 'Detail')">
						{{JSON.stringify(item)}}
					</view>
				</view>
			</view>
		</view>
		<view v-show="current == 1">
			<u-empty text="暂无审批记录" :show="noApprovalData" mode="list"></u-empty>
			<view v-show="!noApprovalData">
				<view v-for="(item,index) in approvalList" :key="index">
					<view class="" @click="toDetail(item, 'Approval')">
						{{JSON.stringify(item)}}
					</view>
				</view>
			</view>
		</view>
		<u-button type="primary" @click="toDetail({}, 'Apply')">新增申请</u-button>
	</view>
</template>

<script>
	import userMixins from '@/libs/userMixins.js'
	export default {
		mixins: [userMixins],
		components: {},
		data() {
			return {
				list: [
					{
						name: '申请列表'
					}, 
					{
						name: '审核列表'
					},
				],
				current: 0,
				applyList: [],
				approvalList: []
			}
		},
		onShow() {
			this.fetchData();
		},
		methods: {
			setCurrent(index) {
				this.current = index;
				this.fetchData()
			},
			fetchData() {
				if (this.showTab) {
					if (this.current == 0) {
						this.fetchApplyData();
					} else {
						this.fetchApprovalData();
					}
				} else {
					this.fetchApplyData();
				}
			},
			fetchApplyData() {
				setTimeout(()=> {
					this.applyList = [
						{
							title: '基于新课程的学校自主发展研究'
						}
					];
				}, 1000)
			},
			fetchApprovalData() {
				setTimeout(()=> {
					this.approvalList = [
						{
							title: '高中数学小本课程开发的研究'
						}
					];
				}, 1000)
			},
			toDetail(item, type) {
				uni.navigateTo({
					url: `research${type}?info=${JSON.stringify({item})}`
				})
			}
		},
		computed: {
			showTab() {
				// let canApproval = this.calMenuShow('审批身份');
				let canApproval = true;
				return canApproval;
			},
			noApplyData() {
				return this.applyList.length == 0
			},
			noApprovalData() {
				return this.approvalList.length == 0
			}
		}
	}
</script>

<style lang="scss" scoped>
	
	
</style>
